package cn.com.dhc.danlu.util;

/**
 * @author: 李一方
 * @time: 2016-09-29 10:47
 * @mail: liyifang@danlu.com
 * @desc: 角标计数工具类
 */
public class TipCountUtil {
    public static final int BIG_FLAG = 999;
    public static final int SMALL_FLAG = 99;

    /**
     * 转换角标
     *
     * @param original
     *         原值数据
     * @param flag
     *         设定阈值,超过该值后显示 "值+"
     * @return 转换后的字符串
     */
    public static String cover (String original, int flag) {
        if (flag <= 0) {
            flag = 99;
        }

        try {
            return (Integer.parseInt (original) > flag) ? (flag + "+") : original;
        } catch (NumberFormatException e) {
            return "0";
        }
    }

    /**
     * 转换角标
     *
     * @param original
     *         原值数据
     * @param flag
     *         设定阈值,超过该值后显示 "值+"
     * @return 转换后的字符串
     */
    public static String cover (int original, int flag) {
        if (flag <= 0) {
            flag = 99;
        }

        return (original > flag) ? (flag + "+") : (original + "");
    }
}